package com.yugao.fintech.antelope.pay.payment.controller.payorder;

import com.yugao.fintech.antelope.base.security.annotation.Anonymous;
import com.yugao.fintech.antelope.base.log.OperateLog;
import com.yugao.fintech.antelope.pay.common.annotation.PayCheck;
import com.yugao.fintech.antelope.pay.model.rqrs.pay.payorder.PayOrderQO;
import com.yugao.fintech.antelope.pay.model.rqrs.pay.payorder.PayOrderRS;
import com.yugao.fintech.antelope.pay.payment.process.payorder.QueryOrderProcess;
import com.yugao.fintech.antelope.pay.validation.PaySignGroup;
import com.yugao.fintech.framework.assistant.utils.exception.BizException;
import com.yugao.fintech.framework.core.response.Resp;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商户查单controller
 */
@Slf4j
@RestController
@Anonymous
public class QueryOrderController {

    @Autowired
    private QueryOrderProcess queryOrderProcess;

    /**
     * 查单接口
     */
    @OperateLog(isSaveDb = false)
    @PostMapping("/pay/getOrder")
    @PayCheck
    public Resp<PayOrderRS> getOrder(@RequestBody @Validated(value = PaySignGroup.class) PayOrderQO rq) {
        if (StringUtils.isAllEmpty(rq.getMchOrderNo(), rq.getPayOrderNo())) {
            throw new BizException("mchOrderNo 和 payOrderNo不能同时为空");
        }
        return queryOrderProcess.getPayOrder(rq);
    }

}
